package com.example.smartplay.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.smartplay.entity.Club;
import com.example.smartplay.entity.Student;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 
 * @since 2024-07-11
 */
@Mapper
public interface StudentMapper extends BaseMapper<Student> {
    // 根据用户名查询
    @Select("select * from student where username = #{username}")
    Student findByUsername(String username);

    // 注册
    @Insert("insert into student(username, password) values(#{username}, #{password})")
    void insert();
    // 根据邮箱查询
    @Select("select * from user where email = #{email}")
    Student findByEmail(String email);
    // 注册
    @Insert("insert into student(username, password) values(#{username}, #{md5PwdStr})")
    void insert1(String username, String md5PwdStr);


    // 从user表查询所有身份为"1"的学生
    @Select("select s.* from user u join student s on u.student_id = s.id where u.level = 1")
    List<Student> selectAllHeaders(Student student);
    // 根据学生id查询学生信息
    @Select("select * from student where id = #{studentId}")
    Student selectByStudentId(Integer studentId);
}
